using HKB.Common;
using System;
using System.Text;
namespace HKB.Web
{
	public class RegProtocal
	{
		public static string ErrMsg = "";
		public static bool Save(string ProtocalCotent)
		{
			FileIO fileIO = new FileIO();
			string str = AppSetings.Get("InstallDir");
			Encoding encoding = Encoding.GetEncoding("utf-8");
			string truePath = fileIO.GetTruePath(str + "App_Data/Protocal.txt");
			bool result;
			try
			{
				fileIO.CreateFile(truePath, ProtocalCotent, encoding);
			}
			catch (Exception ex)
			{
				RegProtocal.ErrMsg = ex.Message.ToString();
				result = false;
				return result;
			}
			result = true;
			return result;
		}
		public static string Get()
		{
			FileIO fileIO = new FileIO();
			string str = AppSetings.Get("InstallDir");
			Encoding encoding = Encoding.GetEncoding("utf-8");
			string result = "";
			string truePath = fileIO.GetTruePath(str + "App_Data/Protocal.txt");
			try
			{
				result = fileIO.ReadFromFile(truePath);
			}
			catch
			{
				throw new Exception("打开注册协议失败，请检查文件：</br>“" + fileIO.GetWebPath(truePath) + "”</br>是否存在！");
			}
			return result;
		}
	}
}
